package com.kevin.wiki.controller;

import com.kevin.wiki.domain.Test;
import com.kevin.wiki.service.TestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author kevin.lv
 * @date 2022/2/22 17:39
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @Value("${test.hello:TEST}")
    private String testHello;

    @Resource
    private TestService testService;

    //http://127.0.0.1:8880/hello
    @RequestMapping(value = "/hello", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public String hello() {
        return testHello;
    }

    @PostMapping(value = "/hello/post", produces = MediaType.APPLICATION_JSON_VALUE)
    public String helloPost(String name) {
        return "hello world! post," + name;
    }

    @GetMapping(value = "/list")
    public List<Test> list() {
        return testService.list();
    }
}
